/*
 * Copyright 2010 Biz-e (info@biz-e.nl)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.biz_e.appengine.gar.client.ui;

import nl.biz_e.appengine.gar.client.GastouderRegistratie;
import nl.biz_e.appengine.gar.client.i18n.Constants;
import nl.biz_e.appengine.gar.client.i18n.GarConstants;
import nl.biz_e.appengine.gar.shared.Role;
import nl.biz_e.gwt.baselib.ui.client.menu.IMenuItem;
import nl.biz_e.gwt.baselib.ui.client.menu.MenuItem;
import nl.biz_e.gwtappengine.lib.client.BaseAppEngineAppPanel;

import com.google.gwt.user.client.ui.Label;

/**
 * This is the main application panel that will be shown
 * right after the user logs in.
 * 
 * @author Joost A. Bloemsma
 */
public class GarPanel extends BaseAppEngineAppPanel {
    private IMenuItem menuParents;
    private IMenuItem menuMinders;
    private IMenuItem menuBuros;
    private IMenuItem menuUsers;
    private static GarConstants constants = Constants.getGarConstants();

    private GastouderRegistratie appMan;

    /**
     * Constructs a new GarPanel instance
     */
    public GarPanel(GastouderRegistratie appMan) {
        super();
        this.add(new Label("Dit is Gastouder Registratie"));
        this.removeAllMenuItems();
        this.appMan = appMan;
        Role role = appMan.getCurrentUser().getRole();
        if (role == Role.admin) {
            menuUsers = new MenuItem(constants.users(), true);
            this.addMenuItem(menuUsers);
            menuParents = new MenuItem(constants.parents(), true);
            this.addMenuItem(menuParents);
            menuMinders = new MenuItem(constants.childminders(), true);
            this.addMenuItem(menuMinders);
            menuBuros = new MenuItem(constants.buros(), true);
            this.addMenuItem(menuBuros);
        }

        if (role == Role.buro) {
            menuParents = new MenuItem(constants.parents(), true);
            this.addMenuItem(menuParents);
            menuMinders = new MenuItem(constants.childminders(), true);
            this.addMenuItem(menuMinders);
        }

        if (role == Role.childMinder) {
            menuParents = new MenuItem(constants.parents(), true);
            this.addMenuItem(menuParents);
            menuBuros = new MenuItem(constants.buros(), true);
            this.addMenuItem(menuBuros);
        }

        if (role == Role.parent) {
            menuMinders = new MenuItem(constants.childminders(), true);
            this.addMenuItem(menuMinders);
            menuBuros = new MenuItem(constants.buros(), true);
            this.addMenuItem(menuBuros);
        }
    }
}
